﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace UI.UserInfo
{
    public partial class addnewUser : Form
    {
       public  UI.UserInfo.UserInfo uInfo;
        DataTable dt = null;
        public addnewUser()
        {
            InitializeComponent();
        }


        private void btn_add_Click(object sender, EventArgs e)
        {
            int s = skinComboBox1.SelectedIndex;
            Model.UserInfo uf = new Model.UserInfo();
            if (s == 0)
            {
                uf.Sex = 0;
            }
            if (s == 1)
            {
                uf.Sex = 1;
            }
            uf.Name = btn_uname.Text;
            uf.Password = btn_pwd.Text;
            uf.Qq = btn_qq.Text;
            uf.Phone = btn_phone.Text;
            uf.Address = btn_address.Text;
            uf.Detail = DateTimePicker.Text;
            if (btn_uname.Text == "" || btn_uname.Text == null || btn_pwd.Text == "" || btn_pwd.Text == null || btn_qq.Text == null || btn_qq.Text == "" || btn_phone.Text == null || btn_phone.Text == "" || btn_address.Text == "" || btn_address.Text == null || DateTimePicker.Text == "" || DateTimePicker.Text == null)
            {
                MessageBox.Show("您有什么没有输入");
                return;
            }
           int combindex = comboBox1.SelectedIndex;
           int jobid = Convert.ToInt32(dt.Rows[combindex][0]);
           uf.Jobid = jobid;
           int i = Convert.ToInt32(BLL.UserManager.Register(uf));
           if (i == 1)
           {
               MessageBox.Show("注册成功");
               this.Close();
           }
     
           uInfo.reloadDataTable();
          // MessageBox.Show(Convert.ToString(jobid));




        }

        private void btn_pwd_Paint(object sender, PaintEventArgs e)
        {

        }

        private void btn_uname_Paint(object sender, PaintEventArgs e)
        {

        }

        private void addnewUser_Load(object sender, EventArgs e)
        {
            dt = new DataTable();

            dt = BLL.UserManager.departjob_3().Tables[0];
            for (int i = 0; i < dt.Rows.Count;i++ )
            {
                comboBox1.Items.Add(dt.Rows[i][2]);
            }

        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        private void btn_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
